<?php

/**

 * Joomla! 1.5 component Folder Space Quota

 *

 * @version $Id: folderspacequota.php 2011-01-24 10:48:13 svn $

 * @author DoggyDams

 * @package Joomla

 * @subpackage Folder Space Quota

 * @license GNU/GPL

 *

 * Control used space of specific directory

 *

* @Copyright Copyright (C) 2010 - DoggyDamss
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html 


 *

 */



// no direct access
defined('_JEXEC') or die('Restricted access');

if ($_POST['totalsize']) {
require_once("../administrator/components/com_folderspacequota/class/folder_space.class.php");

$data = array('total'=>$_POST['totalsize'], 'max_height'=>100, 'max_width'=>15, 'axis'=> 'vertical', 'bar_name'=> 'Quota', 'dir'=> $source.'../', 'empty_color'=>'#F1F2F3', 'full_color'=>'#0b55c4', 'float'=>'left', 'var_dump'=> false ); $fldr = new handle();

echo '<br/><div style="color:#0b55c4;font-weight:bold;font-size:12px;padding:5px;">
'.JText::_( 'TOTAL_SIZE').'
</div><br/><br/>';
$fldr->create($data);
}
	
elseif ($_GET['totalsize']) {
echo '<div style="color:#0b55c4;font-size:12px;text-align:justify;padding:5px;">
'.JText::_( 'INTRO_FORM').'
<br/><br/><br/><form action="index3.php?option=com_folderspacequota" method="post">
'.JText::_( 'FORM_SELECT').'
<br/><br/><center>
<select name="totalsize">
<option value="209715200">200MB</option>
<option value="524288000">500MB</option>
<option value="1073741824">1GB</option>
<option value="2147483648">2GB</option>
<option value="5368709120">5GB</option>
<option value="10737418240">10GB</option>
<option value="21474836480">20GB</option>
</select><br/><br/>
<input type="submit" value="GO !"/>
</center>
</form></div>
';
}

else {

$imgPath3 = JRoute::_('/administrator/components/com_folderspacequota/icons/quotatree.png');
JFactory::getDocument()->addStyleDeclaration(".icon-48-quotatree { background: url($imgPath3); }");
JToolBarHelper::title(JText::_('Folder Space Quota'), 'quotatree.png');

JToolBarHelper::preferences('com_folderspacequota',$height='425');

function file_size_info($filesize) { 
 $bytes = array('Bytes', 'KB', 'MB', 'GB', 'TB'); # values are always displayed  
 if ($filesize < 1024) $filesize = 1; # in at least kilobytes. 
 for ($i = 0; $filesize > 1024; $i++) $filesize /= 1024; 
 $file_size_info['size'] = ceil($filesize); 
 $file_size_info['type'] = $bytes[$i]; 
 return $file_size_info; 
}

require_once("../configuration.php");
$jconfig = new JConfig();

$db_error = "I am sorry! We are maintenaning the website, please try again later.";
$db_config = mysql_connect( $jconfig->host, $jconfig->user, $jconfig->password ) or die( $db_error );
mysql_select_db( $jconfig->db, $db_config ) or die( $db_error );

JFactory::getDocument()->addStyleDeclaration("#cpanel div.cpanelicon { text-align: center; margin-right: 5px; margin-bottom: 5px; } #cpanel div.cpanelicon a { display: block; border: 1px solid #f0f0f0; height: 100px; width: 100px; /*color: #666; */ color: blue; vertical-align: middle; text-decoration: none; } #cpanel div.cpanelicon a:hover { border-left: 1px solid #eee; border-top: 1px solid #eee; border-right: 1px solid #ccc; border-bottom: 1px solid #ccc; background: #f9f9f9; color: #0B55C4; }");

echo '<table style="width:100%;"><tr><td colspan="2">
<div style="font-size:14px;color:#0b55c4;text-align:justify;">
'.JText::_( 'QUOTA_INTRO').'
</div><br/><br/></td></tr><tr><td width="66%" valign="bottom">
<center><table style="width:100%" id="cpanel"><tr><td width="33%">
<div class="cpanelicon"><a href="index.php?option=com_folderspacequota&view=quota">
<img src="../administrator/components/com_folderspacequota/icons/quotaf.png">
<br/>
'.JText::_( 'QUOTA_QUOTAS').'</a></div>
</td>
<td width="33%">
<div class="cpanelicon"><a href="index.php?option=com_folderspacequota&view=list">
<img src="../administrator/components/com_folderspacequota/icons/treefold.png">
<br/>
'.JText::_( 'QUOTA_CONTENTS').'</a></div>
</td><td width="33%">';

$rows = mysql_query("SHOW TABLE STATUS"); 
$dbsize = 0; 
while ($row = mysql_fetch_array($rows)) { 
 $dbsize += $row['Data_length'] + $row['Index_length']; 
} 

$dbsize = file_size_info($dbsize); 

echo 'Taille de la Base de Données : '.$dbsize["size"].' '.$dbsize["type"].'<br/><br/>
<a class="modal" rel="{handler: \'iframe\', size: {x: 250, y: 220}}" href="index3.php?option=com_folderspacequota&task=default&totalsize=ask">'.JText::_( 'QUOTA_TOTAL').'&nbsp;&nbsp;<img src="../administrator/components/com_folderspacequota/icons/totalsize.png" style="border:none;text-decoration:none;margin-bottom:-12px;"></a>
</td></tr></table></center></td><td valign="bottom">
<fieldset style="background-color:#F1F2F3;text-align:justify;color:grey">'.JText::_( 'CREDITS').'<br/><br/>
*   Folder Space Folder Quota Class<br/>
*   filename: folder_space.class.php<br/>
*   Php version PHP5 / Revision : 27 / version: 0.2<br/>
*   author: Ersin Güvenç <eguvenc@gmail.com> (C) 2008<br/>
*   Web: http://develturk.com<br/>
*   license http://opensource.org/licenses/lgpl-license.php<br/>
*	GNU Lesser General Public License Version 2.1
</fieldset></td></tr></table>';
}

?>
